package com.bookmanagement.mq;

import com.alibaba.fastjson.JSON;
import com.bookmanagement.DTO.UserAccountDTO;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 用户注册消息生产者
 * @author skyjay
 */
@Component
public class UserRegisterProducer {
    
    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    
    /**
     * 发送用户注册消息
     */
    public void sendRegisterMessage(UserAccountDTO userAccountDTO) {
        String message = JSON.toJSONString(userAccountDTO);
        rocketMQTemplate.convertAndSend("user-register-topic", message);
    }
}
